<?php

namespace app\exam\validate;

use think\Validate;

/**
 * 试卷答案验证
 */
class PaperAnswer extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名'    =>    ['规则1','规则2'...]
     *
     * @var array
     */
    protected $rule = [
        'type'          => 'require|number|in:3,4,5,6',
        'status'        => 'require|number|in:1,2',
        // 'record_id'     => 'require|/^[\d,]+$/',
        'record_id'     => 'require|number',
        'epar_id'       => 'require|number',
        'paper_id'      => 'require|number',
        'part_id'       => 'require|number',
        'topic_id'      => 'require|number',
        'unique_code'   => 'require|/^[\w]+$/',

    ];

    protected $field = [
        'type'          => '类型',
        'status'        => '类型',
        'epar_id'       => '考试记录',
        'paper_id'      => '试卷',
        'part_id'       => '部分',
        'topic_id'      => '试题',
        'unique_code'   => '唯一标识',
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名'    =>    '错误信息'
     *
     * @var array
     */
    protected $message = [
    ];

    /**
     * 验证场景
     */
    protected $scene = [
        'list'          => ['type'],
        'record'        => ['record_id'],
        'topic'         => ['unique_code', 'epar_id', 'part_id', 'topic_id'],
        'paper_users'   => ['status', 'paper_id'],
        'user_fetch'    => ['record_id'],
    ];


}
